package com.yuanli.cosmeticmirror.persenter;

import androidx.lifecycle.LifecycleOwner;

import com.comenjoysoft.baselibrary.listener.CallbackListener;
import com.comenjoysoft.baselibrary.presenter.BasePresenter;
import com.yuanli.cosmeticmirror.model.biz.IFindPwdBiz;
import com.yuanli.cosmeticmirror.model.biz.IUserBiz;
import com.yuanli.cosmeticmirror.model.impl.FindPwdImpl;
import com.yuanli.cosmeticmirror.model.impl.UserImpl;
import com.yuanli.cosmeticmirror.model.iview.IFindPwdView;
import com.yuanli.cosmeticmirror.model.iview.IUserView;

public class UserPersenter extends BasePresenter<IUserView> {

    private final IUserBiz biz;

    public UserPersenter(IUserView view, LifecycleOwner owner) {
        attachView(view);
        biz = new UserImpl(owner);
    }



    public void logoff() {
        biz.logoff(new CallbackListener<String>() {
            @Override
            public void success(String object) {
                if (object.contains("SUCCESS")) {
                    mView.onSucess(1);
                } else if (object.contains("Account does not exist")) {
                    mView.onError("注销账号失败");
                } else {
                    mView.onError("注销账号失败");

                }
            }

            @Override
            public void failed(Object object) {
                mView.onError("注销账号失败");
            }
        });
    }
}
